package config

type CommonSrvConfig struct {
	Name string `mapstructure:"name" json:"name"`
}

type JWTConfig struct {
	SigningKey string `mapstructure:"key" json:"key"`
}

type ConsulConfig struct {
	Host string `mapstructure:"host" json:"host"`
	Port int    `mapstructure:"port" json:"port"`
}

type JaegerConfig struct {
	Host string `mapstructure:"host" json:"host"`
	Port int    `mapstructure:"port" json:"port"`
	Name string `mapstructure:"name" json:"name"`
}

type SentinelQpsConfig struct {
	Resource               string `mapstructure:"resource" json:"resource"`
	Threshold              int    `mapstructure:"threshold" json:"threshold"`
	TokenCalculateStrategy int    `mapstructure:"tokenCalculateStrategy" json:"tokenCalculateStrategy"`
	ControlBehavior        int    `mapstructure:"controlBehavior" json:"controlBehavior"`
	StatIntervalInMs       int    `mapstructure:"statIntervalInMs" json:"statIntervalInMs"`
	WarmUpPeriodSec        int    `mapstructure:"warm_up_period_sec" json:"warm_up_period_sec"`
}

type SentinelBreakerConfig struct {
	Resource         string  `mapstructure:"resource" json:"resource"`
	Strategy         int     `mapstructure:"strategy" json:"strategy"`
	RetryTimeoutMs   int     `mapstructure:"retry_timeout_ms" json:"retry_timeout_ms"`
	MinRequestAmount int     `mapstructure:"min_request_amount" json:"min_request_amount"`
	StatIntervalMs   int     `mapstructure:"stat_interval_ms" json:"stat_interval_ms"`
	Threshold        float64 `mapstructure:"threshold" json:"threshold"`
}

type ServerConfig struct {
	Name                string                  `mapstructure:"name" json:"name"`
	Host                string                  `mapstructure:"host" json:"host"`
	Port                int                     `mapstructure:"port" json:"port"`
	Tags                []string                `mapstructure:"tags" json:"tags"`
	GoodsSrvInfo        CommonSrvConfig         `mapstructure:"goods_srv" json:"goods_srv"`
	InventorySrvInfo    CommonSrvConfig         `mapstructure:"inventory_srv" json:"inventory_srv"`
	JWTInfo             JWTConfig               `mapstructure:"jwt" json:"jwt"`
	ConsulInfo          ConsulConfig            `mapstructure:"consul" json:"consul"`
	JaegerInfo          JaegerConfig            `mapstructure:"jaeger" json:"jaeger"`
	SentinelQpsInfo     []SentinelQpsConfig     `mapstructure:"sentinel_qps" json:"sentinel_qps"`
	SentinelBreakerInfo []SentinelBreakerConfig `mapstructure:"sentinel_breaker" json:"sentinel_breaker"`
}

type NacosConfig struct {
	Host      string `mapstructure:"host"`
	Port      int    `mapstructure:"port"`
	Namespace string `mapstructure:"namespace"`
	User      string `mapstructure:"user"`
	Password  string `mapstructure:"password"`
	DataId    string `mapstructure:"dataid"`
	Group     string `mapstructure:"group"`
}
